package com.zhangxiaofanfan.hotcode.second;

import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Stack;

/**
 *
 *
 * @date 2024-06-29 03:21:25
 * @author zhangxiaofanfan
 */
public class HotCode070 {
    public static void main(String[] args) {
        HotCode070 hotCode = new HotCode070();
    }

}

class MinStack {

    private final Stack<Integer> stack;
    private final PriorityQueue<Integer> priorityQueue;

    public MinStack() {
        stack = new Stack<>();
        priorityQueue = new PriorityQueue<>();
    }

    public void push(int val) {
        priorityQueue.add(val);
        stack.push(val);
    }

    public void pop() {
        priorityQueue.remove(stack.pop());
    }

    public int top() {
        return stack.peek();
    }

    public int getMin() {
        return priorityQueue.peek();
    }
}

